package com.example.bond_svc.controller;

import com.example.bond_svc.model.BidRequest;
import com.example.bond_svc.model.BidResult;
import com.example.bond_svc.service.AuctionService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auctions")
public class AuctionController {
    private final AuctionService auctionService;

    public AuctionController(AuctionService auctionService) {
        this.auctionService = auctionService;
    }

    @PostMapping("/{auctionId}/bids")
    public ResponseEntity<BidResult> submitBid(
            @PathVariable Long auctionId,
            @RequestBody BidRequest request) {
        BidResult result = auctionService.processBid(auctionId, request);
        return ResponseEntity.ok(result);
    }
}